package com.example.vue.sys.action;

import com.example.vue.sys.service.SysRoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Map;

/**
 * 角色管理的 action
 *
 * @author zhouxl
 * @DATE 2020/12/9
 * @descriptoin
 */
@Controller
@RequestMapping("/api/sysRole")
public class SysRoleAction {

    @Autowired
    private SysRoleService sysRoleService;

    /**
     * 添加角色
     *
     * @return
     */
    @RequestMapping(value = "addRole", method = RequestMethod.POST)
    @ResponseBody
    public Object addRole(@RequestParam Map<String, Object> params) {
        return sysRoleService.addRole(params);
    }

    /**
     * 查询角色列表信息
     *
     * @return
     */
    @RequestMapping(value = "queryRoleList", method = RequestMethod.POST)
    @ResponseBody
    public Object queryRoleList(@RequestParam Map<String, Object> params) {
        return sysRoleService.queryRoleList(params);
    }

    /**
     * 编辑保存角色信息
     *
     * @param params
     * @return
     */
    @RequestMapping(value = "editRole", method = RequestMethod.POST)
    @ResponseBody
    public Object editRole(@RequestParam Map<String, Object> params) {
        if (1 / 0 == 0) {

        }
        return sysRoleService.editRole(params);
    }

    /**
     * 删除角色信息
     *
     * @param params
     * @return
     */
    @RequestMapping(value = "deleteRole", method = RequestMethod.POST)
    @ResponseBody
    public Object deleteRole(@RequestParam Map<String, Object> params) {
        return sysRoleService.deleteRole(params);
    }

    /**
     * 查询角色对应的菜单信息
     *
     * @return
     */
    @RequestMapping(value = "queryRoleMenuTree", method = RequestMethod.POST)
    @ResponseBody
    public Object queryRoleMenuTree(@RequestParam Map<String, Object> params) {
        return sysRoleService.queryRoleMenuTree(params);
    }

    /**
     * 保存角色权限信息
     *
     * @param params
     * @return
     */
    @RequestMapping(value = "saveRoleMenu", method = RequestMethod.POST)
    @ResponseBody
    public Object saveRoleMenu(@RequestParam Map<String, Object> params) {
        return sysRoleService.saveRoleMenu(params);
    }


    /**
     * 查询下拉框的角色信息列表
     *
     * @param params
     * @return
     */
    @RequestMapping(value = "querySelectRoleList", method = RequestMethod.POST)
    @ResponseBody
    public Object querySelectRoleList(@RequestParam Map<String, Object> params) {
        return sysRoleService.querySelectRoleList(params);
    }
}


